package com.nw.news.base;

import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;


public abstract class BaseActivity extends AppCompatActivity {
    private static final int FAST_CLICK_INTERVAL = 500;//快速点击间隔
    private long lastClickTime;//last click time

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//全局只能竖屏
        setContentView(getLayoutId());
        init();
    }

    public abstract int getLayoutId();

    public abstract void init();

    public void showToast(int id) {
        String ssdf = getString(id);
        showToast(ssdf);
    }

    public void showToast(String text) {
        if (!TextUtils.isEmpty(text)) {
            //if (mToast == null) {
        }
    }

    /**
     * 判断是否是快速点击
     *
     * @return
     */
    public boolean isFastClick() {
        long now = System.currentTimeMillis();
        if (now - lastClickTime < FAST_CLICK_INTERVAL) {
            return true;
        }
        lastClickTime = now;
        return false;
    }

}
